import { PORT1 } from '@/api/config/servicePort';
import http from '@/api';
import { PublicParams } from '@/api/interface/publicParams';
import { RoleInterface } from '@/api/interface/auth/role';

/**
 *  根据用户角色绑定
 */
export const roleUserBindingRole = (params: PublicParams.ResBindingId) => {
  return http.post(PORT1 + `/role/v1/userBindingRole`, params);
};

/**
 *  新增|保存角色
 */
export const roleSave = (params: RoleInterface.ReqSave) => {
  return http.post(PORT1 + `/role/v1/save`, params);
};

/**
 *  修改角色状态
 */
export const roleUpdateStatus = (params: PublicParams.ReqStatus) => {
  return http.post(PORT1 + `/role/v1/updateStatus`, params);
};

/**
 *  查询所有角色
 */
export const roleFindList = () => {
  return http.get<RoleInterface.RoleInfo[]>(PORT1 + `/role/v1/findList`);
};

/**
 *  根据用户id查询绑定的角色id
 */
export const roleFindListByUserId = (params: PublicParams.ReqId) => {
  return http.get<Array<number>>(PORT1 + `/role/v1/findListByUserId`, params);
};

/**
 *  删除角色
 */
export const roleDeleteById = (params: PublicParams.ReqId) => {
  return http.get(PORT1 + `/role/v1/deleteById/${params.id}`);
};
